package com.donzell.web.controller.front;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.donzell.model.EcsUsers;
import com.donzell.service.UserService;

@RestController
@RequestMapping(value = "/frame")
public class UserController {
	@Autowired
	private UserService userService;

	@RequestMapping(value="/test", method = RequestMethod.GET)
	public EcsUsers test(){
		System.out.println("1111111");
		return userService.getOneUser();
	}
	
	@RequestMapping(value = "/saveUser", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE
			+ ";charset=UTF-8")
	public String saveUser(@RequestBody EcsUsers user) {
		return userService.add(user);
	}

	@RequestMapping(value = "/saveUser/{account}", method = RequestMethod.GET)
	public String add(@PathVariable String account) {
		return userService.addUser(account);
	}

	@RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
	public EcsUsers add(@PathVariable Long id) {
		return userService.getOneUser(id);
	}
}